﻿@page
@model ToolGood.SqlOnline.Pages.Admins.User.ChangeManagerPasswordModel
@{
    Layout = "~/Pages/Shared/_Layout_Edit.cshtml";
}
<style>
    .layui-form-item .layui-input-inline { width: 300px; }
</style>
<form id="editForm">
    @Html.AntiForgeryToken()
    <div class="layui-form-item" style="padding-top: 24px; text-align:center;">
        <div id="hidden" class="hidden" style="display:none;width:0;height:0;">
            <input type="text" name="username" id="username" value="test" autocomplete="on" maxlength="20" required="" placeholder="请输入用户名" style="display:none" />
            <input type="password" name="password" id="password" value="fuckAutocomplete" autocomplete="on" maxlength="20" required="" placeholder="请输入密码" style="display:none" />
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">旧密码 <span class="red">*</span></label>
            <div class="layui-input-inline">
                <input type="password" name="OldPassword" id="OldPassword" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">新密码 <span class="red">*</span></label>
            <div class="layui-input-inline">
                <input type="password" name="NewPassword" id="NewPassword" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">确认密码 <span class="red">*</span></label>
            <div class="layui-input-inline">
                <input type="password" name="ConfirmPassword" id="ConfirmPassword" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div style="text-align:center;">
            <button type="button" class="layui-btn layui-btn-primary" onclick="save(this)"> 保 存 </button>
            <button type="button" class="layui-btn layui-btn-primary" onclick="closeWindow()"> 关 闭 </button>
        </div>
    </div>
</form>

@section js{
    <script>
        $(function () {
            $("input#OldPassword").keyup(function (key) { if (key.keyCode == 13) { $("input#NewPassword").focus(); } });
            $("input#NewPassword").keyup(function (key) { if (key.keyCode == 13) { $("input#ConfirmPassword").focus(); } });
            $("input#ConfirmPassword").keyup(function (key) { if (key.keyCode == 13) { save(); } });
        });
        function save(obj) {
            var NewPassword = $("#NewPassword").val();
            var ConfirmPassword = $("#ConfirmPassword").val();
            var OldPassword = $("#OldPassword").val();
            if (OldPassword.length < 3) {
                layer.msg("请输入旧密码。");
                return;
            }
            if (NewPassword.length < 3) {
                layer.msg("请输入新密码。");
                return;
            }
            if (ConfirmPassword.length < 3) {
                layer.msg("请输入确认密码。");
                return;
            }
            if (NewPassword != ConfirmPassword) {
                layer.msg("请核对新密码。");
                return;
            }
             $(obj).prop("disabled", true);
            var url = "./Ajax/AdminMemberChangeManagerPassword";
            var data = $("#editForm").serializeJson();
            $.adminModePost(url, data, function () {
                closeWindow();
            }, function () {
                    $(obj).prop("disabled", false);
                if (data.message) {
                    layer.msg(data.message);
                } else {
                    layer.msg("出错了");
                }
            });
        }
    </script>

}